﻿var pub_fun_name = "积分";

// 头像
function function_url_name (str,num) {
  var start =  0;
  var lenght = str.length-1;
  var string = str.substr(start,lenght);
  string = string+''+num+'';
  return string;  
}

// 图片路径转换
function img_url(url){
  var path;
  if(url.indexOf("http")!=-1){
    path = url;
  }
  else
  {
    path = pub_upload_root_url + url;
  }
  return path;
}

;(function (doc, win) {
  var docEl = doc.documentElement,
  resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
  recalc = function () {
    var clientWidth = docEl.clientWidth;
    if (!clientWidth) return;
    docEl.style.fontSize = 20 * (clientWidth / 320) + 'px';
  };

  if (!doc.addEventListener) return;
  win.addEventListener(resizeEvt, recalc, false);
  doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);

function func_alert(mes, callback)
{
  var html = '<div id="alertWin" class="weui_dialog_alert">' +
  '<div class="weui_mask"></div>' +
  '<div class="weui_dialog">' +
  '<div class="weui_dialog_hd"><strong class="weui_dialog_title">提示</strong></div>' +
  '<div class="weui_dialog_bd">' + mes + '</div>' +
  '<div class="weui_dialog_ft">' +
  '<a id="alertPrimary" href="#" class="weui_btn_dialog primary">确定</a>' +
  '</div>' +
  '</div>' +
  '</div>';
  $('body').append(html);

  $('#alertPrimary').click(function ()
  {
    callback && callback();
    $('#alertWin').remove();
  });
}
// mes 内容 ，
// _default 取消按钮字，
// _primary 确定按钮字 
// callback 取消按钮回调方法
// callback1 确定按钮回调方法
function func_confirm(mes, _default, _primary, callback, callback1)
{
  var html = '<div id="confirmWin" class="weui_dialog_confirm">' +
  '<div class="weui_mask"></div>' +
  '<div class="weui_dialog">' +
  '<div class="weui_dialog_hd"><strong class="weui_dialog_title">提示</strong></div>' +
  '<div class="weui_dialog_bd">' + mes + '</div>' +
  '<div class="weui_dialog_ft">' +
  '<a href="#" class="weui_btn_dialog default">取消</a>' +
  '<a href="#" class="weui_btn_dialog primary">确定</a>' +
  '</div>' +
  '</div>' +
  '</div>';

  $('body').append(html);
  if (_default)
  {
    $('#confirmWin').find('.default').html(_default);
  }
  if (_primary)
  {
    $('#confirmWin').find('.primary').html(_primary);
  };
  $('#confirmWin').find('.default').click(function ()
  {
    callback && callback.call();
    $('#confirmWin').remove();
  });
  $('#confirmWin').find('.primary').click(function ()
  {
    callback1 && callback1.call();
    $('#confirmWin').remove();
  });
}


